#include <bits/stdc++.h>

using namespace std;

const int MAXN = 5e5+10;

char s[MAXN];
int cnt,f[MAXN][3][3],g[MAXN][3][3];

int dfs(int &cur){
	int x = ++cnt;
	if(s[cur] == '0'){
		for(int i = 0;i < 3;i++)
			f[x][i][i] = g[x][i][i] = 1;
	}else if(s[cur] == '1'){
		cur++;
		int y = dfs(cur);
		memset(f[x],0x3f,sizeof(f[x]));
		memset(g[x],0,sizeof(g[x]));
		for(int i = 0;i < 3;i++)
			for(int j = 0;j < 3;j++)
				if(i != j){
					for(int k = 0;k < 3;k++){
						f[x][i][k] = min(f[x][i][k],f[y][j][k] + (i == k));
						g[x][i][k] = max(g[x][i][k],g[y][j][k] + (i == k));
					}
				}
	}else{
		cur++;
		int ls = dfs(cur);
		cur++;
		int rs = dfs(cur);
		memset(f[x],0x3f,sizeof(f[x]));
		memset(g[x],0,sizeof(g[x]));
		for(int i = 0;i < 3;i++)
			for(int j = 0;j < 3;j++)
				if(i != j)
					for(int k = 0;k < 3;k++)
						if(k != i && k != j)
							for(int d = 0;d < 3;d++){
								f[x][i][d] = min(f[x][i][d],f[ls][j][d] + f[rs][k][d] + (i == d));
								g[x][i][d] = max(g[x][i][d],g[ls][j][d] + g[rs][k][d] + (i == d));
							}
	}
	return x;
}

int main (){
	scanf("%s",s+1);
	int cur = 1;
	dfs(cur);
	int mx = 0,mn = strlen(s+1);
	for(int i = 0;i < 3;i++){
		mx = max(mx,g[1][i][0]);
		mn = min(mn,f[1][i][0]);
	}
	printf("%d %d\n",mx,mn);
	return 0;
}
